package com.xmbandu.app.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;

import com.xmbandu.app.R;
import com.xmbandu.app.base.BaseActivity;
import com.xmbandu.app.bean.LinkBean;
import com.xmbandu.app.home.MainActivity;
import com.xmbandu.app.httpnet.BaseObserver;
import com.xmbandu.app.httpnet.RetrofitFactory;
import com.xmbandu.app.utils.SspPrefUtils;
import com.xmbandu.app.utils.ThreadUtils;

import io.reactivex.Observable;


/**
 * 启动页
 */
public class GuideActivity extends BaseActivity {
    @Override
    public int getLayoutId() {
        return R.layout.activity_guide;
    }

    @Override
    public void initViews() {

        ThreadUtils.postDelayOnUI(new Runnable() {
            @Override
            public void run() {
                if (!SspPrefUtils.getString("token", "").isEmpty()) {
                    Intent intent = new Intent(GuideActivity.this, MainActivity.class);
                    startActivity(intent);
                    finish();
                } else {
                    Intent intent = new Intent(GuideActivity.this, LoginActivity.class);
                    startActivity(intent);
                    finish();
                }
            }
        }, 3000);


    }


    @Override
    public void initListener() {

    }

    @Override
    public void initData() {
//        Observable observable = RetrofitFactory.getInstance().getLink();
//        observable.compose(compose(this.bindToLifecycle())).subscribe(new BaseObserver<LinkBean>(this) {
//            @Override
//            protected void onHandleSuccess(LinkBean linkBean) {
//                Log.e("", "onHandleSuccess: "+linkBean.getUrl() );
//                if(!TextUtils.isEmpty(linkBean.getUrl())){
//                    SspPrefUtils.setString("weburl",linkBean.getUrl());
//                }
//
//            }
//
//
//        });

    }

    @Override
    public void processClick(View v) {

    }
}
